#include "qopenharmonycamerasession.h"
#include "qopenharmonycamerainfocontrol.h"

QT_BEGIN_NAMESPACE

QCamera::Position QOPenHarmonyCameraInfoControl::cameraPosition(const QString &deviceName) const
{
    return position(deviceName);
}

int QOPenHarmonyCameraInfoControl::cameraOrientation(const QString &deviceName) const
{
    return orientation(deviceName);
}

QCamera::Position QOPenHarmonyCameraInfoControl::position(const QString &deviceName)
{
    const QList<OPenHarmonyCameraInfo> &cameras = QOPenHarmonyCameraSession::availableCameras();
    for (int i = 0; i < cameras.count(); ++i) {
        const OPenHarmonyCameraInfo &info = cameras.at(i);
        if (QString::fromLatin1(info.name) == deviceName)
            return info.position;
    }

    return QCamera::UnspecifiedPosition;
}

int QOPenHarmonyCameraInfoControl::orientation(const QString &deviceName)
{
    const QList<OPenHarmonyCameraInfo> &cameras = QOPenHarmonyCameraSession::availableCameras();
    for (int i = 0; i < cameras.count(); ++i) {
        const OPenHarmonyCameraInfo &info = cameras.at(i);
        if (QString::fromLatin1(info.name) == deviceName)
            return info.orientation;
    }

    return 0;
}

QT_END_NAMESPACE
